//
//  AWSTableviewAdapter.h
//  AWSBase
//
//  Created by AlanWang on 2018/2/26.
//  Copyright © 2018年 AlanWang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
//不实现cell block的话要先在tableview注册所有的cell
//自动选择展示时 数据源model一定要实现这个方法
@protocol JFTableviewAdapterDataSourceDelegate <NSObject>
@required
-(NSString*)identifier;
-(Class)identifierClass;
@optional
//建议实现cell内的方法获取高度
-(double)cellHeight;
@end
//自动选择展示时 cell一定要实现这个方法
@protocol JFTableviewAdapterConfigCellVauleDelegate <NSObject>
@required
-(void)cellConfigVaule:(id)vaule indexPath:(NSIndexPath *)indexPath;
+(double)cellHeightWithVaule:(id)vaule;
@end

typedef NSUInteger(^AWSTableviewAdapterNumberOfSectionsInTableViewBlock)(UITableView *tableView);
typedef NSUInteger(^AWSTableviewAdapterNumberOfRowsInSectionViewBlock)(UITableView *tableView,NSInteger section);
typedef CGFloat(^AWSTableviewAdapterHeightForRowAtIndexPathBlock)(UITableView *tableView,NSIndexPath *indexPath);
typedef CGFloat(^AWSTableviewAdapterHeightForViewInSectionBlock)(UITableView *tableView,NSInteger section);
typedef UIView*(^AWSTableviewAdapterViewInSectionBlock)(UITableView *tableView,NSInteger section);
typedef UITableViewCell*(^AWSTableviewAdapterCellForRowAtIndexPathBlock)(UITableView *tableView,NSIndexPath *indexPath);
typedef void (^AWSTableviewAdapterCellWillReturnBlock)(UITableView *tableView,NSIndexPath *indexPath ,UITableViewCell* cell);
typedef void(^AWSTableviewAdapterdidSelectRowAtIndexPathBlock)(UITableView * tableView,NSIndexPath *indexPath);

@interface JFTableviewAdapter : NSObject<UITableViewDelegate,UITableViewDataSource>
//数据源
@property(nonatomic,copy) NSArray * data;//数据源
-(BOOL)registerCellWithMoldelClass:(UITableView*)tableview modelClassName:(NSArray*)modelClassArr cellClassName:(NSString*)cellClassNameOrXibName;

//优先于类内实现,为了不继承类实现微调调整
@property(nonatomic,copy) AWSTableviewAdapterNumberOfSectionsInTableViewBlock  numberOfSections;
@property(nonatomic,copy) AWSTableviewAdapterNumberOfRowsInSectionViewBlock  numberOfRows;
@property(nonatomic,copy) AWSTableviewAdapterHeightForRowAtIndexPathBlock  heightForRow;
@property(nonatomic,copy) AWSTableviewAdapterHeightForViewInSectionBlock  heightForSectionHeader;
@property(nonatomic,copy) AWSTableviewAdapterHeightForViewInSectionBlock  heightForSectionFooter;
@property(nonatomic,copy) AWSTableviewAdapterViewInSectionBlock  sectionHeaderView;
@property(nonatomic,copy) AWSTableviewAdapterViewInSectionBlock  sectionFooterView;
@property(nonatomic,copy) AWSTableviewAdapterCellForRowAtIndexPathBlock  cellForRowAtIndexPath;
@property(nonatomic,copy) AWSTableviewAdapterdidSelectRowAtIndexPathBlock  didSelectRowBlock;
//全部交给cell 处理时，会在cell return的时候执行
@property(nonatomic,copy) AWSTableviewAdapterCellWillReturnBlock  cellWillReturnBlock;
@end
